package com.aiex.framework.db.config.utils;

import cn.hutool.core.bean.BeanUtil;
import com.aiex.framework.db.config.base.PageDTO;

import java.util.List;

public class PageUtils {

    /**
     * 拷贝
     * @param page
     * @param tClass
     * @return
     * @param <T>
     * @param <R>
     */
    public static <T, R> PageDTO<T> copy(PageDTO<R> page, Class<T> tClass){
        List<R> records = page.getList();
        List<T> list = BeanUtil.copyToList(records, tClass);
        //重新赋值
        PageDTO<T> pageResult = new PageDTO<>();
        pageResult.setList(list);
        pageResult.setPageNumber(page.getPageNumber());
        pageResult.setPageSize(page.getPageSize());
        pageResult.setTotal(page.getTotal());
        return pageResult;
    }

}
